import { ref, computed } from "vue";

function useFilteredTodo(todos) {
  const selected = ref("all");
  const filterTodos = computed(() => {
    switch (selected.value) {
      case "done":
        return todos.value.filter((item) => item.templeted === true);
      case "todo":
        return todos.value.filter((item) => item.templeted !== true);
      default:
        return todos.value;
    }
  });

  return { filterTodos, selected };
}

export default useFilteredTodo;
